<?php
include_once('../includes/settings.php');
include_once('../includes/functions.php');
include_once(inc('sql.php'));
include_once(inc('repository.php'));
$user_id = intval(user_val('id'));
$word_id = intval($_REQUEST['word_id']);
$notes=NULL;
?>


<?php
	$type = strtolower($_REQUEST['type']);
	if($type=='all'){
		$notes = Note::get($word_id,$user_id);
	}elseif ($type=="ilike") {
		$notes = Note::get_mime($word_id,$user_id,0);
	}elseif ($type=='mime') {
		$notes = Note::get_mime($word_id,$user_id);
	}
	if($notes):
		$ids=array();
		foreach ($notes as $note) {
			$ids[]=$note['id'];
		}
		$notes_collected_by=Note::notes_collected_by($ids,$user_id);
?>
<?php
	foreach ($notes as $note):
?>
	<div class="a_note" id="note_<?php e($note['id'])?>" note-id="<?php e($note['id'])?>">
		<div class="note_content"><?php e($note['note']); ?></div>
		<div class="actions">
			<?php if($note['is_creator']!="1"):?>
				<?php if( is_exsit($notes_collected_by,'note_id',$note['id'])):?>
					<span>喜欢(<?php e($note['num_of_like']) ?>)</span>
				<?php else: ?>
					<a href="javascript:void(0)" class="like">
					喜欢(<?php e($note['num_of_like']) ?>)
					</a>
				<?php endif ?>	
				<a href="javascript:void(0)" class="dislike">
					不喜欢(<?php e($note['num_of_dislike']) ?>)
				</a>
			<?php else: ?>
				<a href="javascript:void(0)"  class="edit">
					编辑
				</a>
				<a href="javascript:void(0)" class="remove">
					删除
				</a>
				<span>喜欢&nbsp;(<?php e($note['num_of_like']) ?>)</span>
				<span>不喜欢&nbsp;(<?php e($note['num_of_dislike']) ?>)</span>
			<?php endif ?>
		</div>
	</div>
<?php endforeach ?>
<?php else: ?>
<span class="grey_small">抱歉，该分类下还没有笔记。</span>
<?php endif ?>